package cn.codecang.mall.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Knife4jConfiguration
 *
 * @author xiaoluo
 * @date 2023/6/3 15:56
 */
@Configuration
@EnableKnife4j
@EnableSwagger2
public class Knife4jConfiguration {
    @Bean(value = "defaultApi2")
    public Docket defaultApi2() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(new ApiInfoBuilder()
                        .title("mall接口文档")
                        .description("接口信息")
                        .termsOfServiceUrl("https://www.baidu.com/")
                        .contact(new Contact("xiaoluo", "http://127.0.0.1", "247567689@qq.com"))
                        .version("1.0.0")
                        .build())
                .groupName("v1.0")
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.codecang.mall.controller"))
                .paths(PathSelectors.any())
                .build();
    }
}
